﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Golf_Product_Img.aspx.cs"
    Inherits="Golf.WebUI.AdminShow.CommoditiesMmanagement.Golf_Product_Img" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <style type="text/css">
        ._img
        {
            width: 200px;
            padding: 5px;
            float: left;
        }
    </style>

    <script src="../../Script/jquery/jquery-1.4.1-vsdoc.js" type="text/javascript"></script>

    <script type="text/javascript">
        $(function() {
            $("#btn_delImg").click(function() {
                if (confirm("你确定要修改吗？")) {
                    var chk = $(".chk:checked");
                    var imgs = "";
                    if (chk.length == 0) {
                        alert("你需要选中后才可以删除");
                        return false;
                    }
                    var div_ids = "";
                    if (chk.length != 0) {
                        chk.each(function(i, item) {
                            imgs += item.value + ",";
                            div_ids += $(item).attr("title") + ",";
                        });
                        imgs = imgs.substring(0, imgs.length - 1);
                        div_ids = div_ids.substring(0, div_ids.length - 1);
                    }
                    var _div_ids = div_ids.split(',');
                    var id = $("#pro_id").val();
                    $.ajax({
                        type: "POST",
                        contentType: "application/x-www-form-urlencoded",
                        url: "Golf_Product_Img.aspx?" + Math.random(),
                        data: {
                            "Action": "ajax_del_img",
                            "imgs": imgs,
                            "_id": id
                        },
                        success: function(msg) {
                            var _msg = msg.split('|')[0];
                            if (_msg == "0") {
                                alert("删除成功");
                                $.each(_div_ids, function(index, value) {
                                    $("#hid_" + value + "").removeAttr("checked");
                                    $("." + value + "").hide();
                                });
                                //刷新框架
                                window.parent.frames.main.location.reload();
                            }
                            if (_msg == "1") {
                                alert("删除失败");
                            }
                        },
                        error: function(xhr) {
                            alert(xhr.responseText);
                        }
                    });
                }
            });
        });
    </script>

    <script type="text/javascript">
        jQuery(function() {
            $("#btn_addImg").click(function() {
                //h获取ifrom中的的值 默认图片
                var fileName = document.getElementById('img_ifram').contentWindow.document.getElementById('FileName').value;
                if (fileName == "0") { alert("上传图片不能为空！！！"); return false; }
                else { $("#hid_img_ifram").val(fileName); }
            });
        });
    </script>

</head>
<body>
    <form id="form1" runat="server">
    <input type="hidden" value="<%=_Pro_ID %>" id="pro_id" />
    商品编号：<asp:Label ID="labID" runat="server" Text="0"></asp:Label>
    <div>
        <%if (dt.Rows.Count > 0)
          {
              for (int i = 0; i < dt.Rows.Count; i++)
              {
        %>
        <div class="_img <%=dt.Rows[i]["unit"] %>" title="http://<%= HttpContext.Current.Request.Url.Host %>:<%= HttpContext.Current.Request.Url.Port %>/ImageProducts/<%=dt.Rows[i]["Pro_Picture"]%>">
            <input id="hid_<%=dt.Rows[i]["unit"] %>" title="<%=dt.Rows[i]["unit"] %>" type="checkbox"
                class="chk" value="<%=dt.Rows[i]["Pro_Picture"] %>" /><br />
            <img alt="" src="http://<%= HttpContext.Current.Request.Url.Host %>:<%= HttpContext.Current.Request.Url.Port %>/ImageProducts/<%=dt.Rows[i]["Pro_Picture"] %>"
                style="height: 160px; width: 160px; border: 1px solid #ccc;" />
        </div>
        <%}
          } %>
        <div style="clear: both;">
            <input id="btn_delImg" type="button" value="  删 除 图 片  " /></div>
        <br />
        <br />
        <input type="hidden" id="hid_img_ifram" value="0" runat="server" />
        <iframe id="img_ifram" src="Upload.aspx" width="500" height="200"></iframe>
        <asp:Button ID="btn_addImg" runat="server" Text="追加到商品图片列表中" OnClick="btn_addImg_Click" />
    </div>
    </form>
</body>
</html>
